package com.kadron.manager;

import java.io.Serializable;

import org.jboss.seam.core.Interpolator;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;

public abstract class KMessageManager extends KManager implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4461462161814441971L;


	protected void good() {
		StatusMessages.instance().add(StatusMessage.Severity.INFO, Interpolator.instance().interpolate("#{messages.success_msg}"), new Object());
	}
	
	protected void message(String key, StatusMessage.Severity severity) {
		StatusMessages.instance().add(severity, Interpolator.instance().interpolate("#{messages['"+key+"']}"), new Object());
	}
	
	protected void message(String key, StatusMessage.Severity severity, String... params) {
		StringBuilder builder = new StringBuilder(Interpolator.instance().interpolate("#{messages['"+key+"']}"));
		for (String param : params) {
			builder.append(" ");
			builder.append(param);
		}
		StatusMessages.instance().add(severity, builder.toString(), new Object());
	}
	
	protected void bad(String key) {
		StatusMessages.instance().add(StatusMessage.Severity.ERROR, Interpolator.instance().interpolate("#{messages['"+key+"']}"), new Object());
	}
	
}
